import Koa from 'koa'
import Router from 'koa-router'
import bodyparser from 'koa-bodyparser'
import cors from '@koa/cors'

import { registeredRouter } from './router/router.js'
import { sync } from './model/Book.js'

const app = new Koa()
const router = new Router()

app.use(cors())

app.use(bodyparser())

registeredRouter(router)

sync()

app.use(router.routes())

app.listen(8000)